home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / jhtools.exe / REGHELP.TXT < prev    next >
Text File  |  1992-02-08  |  33KB  |  1,334 lines

  1. *
  2.                                *
  3.       *
  4.                        *                      *
  5.  
  6.  
  7.                 *              *              *
  8.      *
  9.                        *           *
  10.  
  11.  
  12.      *             *           *
  13.                                                *
  14.                                    #
  15.                #####      #   #     #    ####
  16.                  #        #   #         #
  17.                  #    *   #####          ###     *
  18.    *             #        #   #             #
  19.               ####        #   #   *     ####
  20.  
  21.  
  22.                                           *
  23.          *
  24.                           *
  25.  
  26.                                                    *
  27.                   *        *          *
  28.  *
  29.  
  30.       ####        ###   ####  #     #  ####   ###
  31.       #           #  #  #  #  #     #  #     #   #
  32.       #       *   ###   #  #  #  #  #  ###   ####       *
  33.  *    #           #     #  #  # # # #  #     # #
  34.       ####        #     ####   #  *#   ####  #  #
  35.                                       *
  36.         *           *
  37.  *                           *                     *
  38.        *
  39.                       *           *
  40.  
  41.  
  42.               *             *
  43.                                          *
  44.            *
  45.                #####  #####   #####   #       ####*
  46.     *            #    #   #   #   #   #      #
  47.                * #    #   #   #   #   #*      ###
  48.                  #    #   #   #   #   #          #
  49.                  #    #####   #####   ####    ###
  50.                 *
  51.                            *                *
  52.      *
  53.            *                         *            *
  54.                          *    VERSION 1.0
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.      Welcome to the JH'S C POWER TOOLS sharewhare manual.  This
  65.  
  66. manual is mainly designed for those c programers who wish to
  67.  
  68. understand how to use the libarary's functions.  If you want to
  69.  
  70. know how the programs work or why they made the way they were you
  71.  
  72. will need to get the expanded manual that comes with the registered
  73.  
  74. version.
  75.  
  76.      The disks that were mailed to you should include the
  77.  
  78. following:
  79.  
  80.      READx.EXE
  81.  
  82.      MENUx.LIB
  83.  
  84.      UTLx.LIB
  85.  
  86.      MOUSx.LIB
  87.  
  88.      KEYx.H
  89.  
  90.      MENx.H
  91.  
  92.      SHAPEx.H
  93.  
  94.      REGHELPx.TXT  (This file)
  95.  
  96. The x by each name is the version number.
  97.  
  98. If you did not receive any of the following please contact me
  99.  
  100. via my E-MAIL number or by regular mail and I will get a
  101.  
  102. replacement copy to you ASAP.
  103.  
  104.      Thank you for you support.
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.      MENUx.C HELP SECTION:
  119.  
  120.  
  121.  
  122.      This is the menu help section.  In this section I will
  123.  
  124. go through each function one by one and explain how to call each
  125.  
  126. function and what it returns.
  127.  
  128.      Before I start with the functions I am going to go over
  129.  
  130. some basics that you will need to know in order to understand
  131.  
  132. the functions.
  133.  
  134.  
  135.  
  136. POINTERS:
  137.  
  138.  
  139.  
  140.      The usefulness of pointers come from the fact that in
  141.  
  142. all C functions varibles are passed by value and since
  143.  
  144. functions only recieve local varibles it can not change the
  145.  
  146. original values that the varible represents.  Pointers make
  147.  
  148. this possible.  Another use for pointers is the manipulating
  149.  
  150. of an array by moving the pointers to its elements.
  151.  
  152.      A pointer is a varible that holds the address of an
  153.  
  154. object (it "points" to the address in memory where the
  155.  
  156. varible is stored.)
  157.  
  158. DEFINATION OF POINTERS:
  159.  
  160.      All C varibles need to be defined and pointers are no
  161.  
  162. different.  Below are some examples of how to declare
  163.  
  164. pointers:
  165.  
  166.      int *ptr;  /* This is a pointer to an interger */
  167.  
  168.      char *buffer;  /* This is a pointer to a character */
  169.  
  170.      char *buffer[]={
  171.  
  172.      " This is a pointer ",
  173.  
  174.      " to an array of ",
  175.  
  176.      " characters ",
  177.  
  178.      ""};
  179.  
  180. In the last case:
  181.  
  182.                  *buffer[1]=this is a pointer
  183.  
  184.                  *buffer[2]=to an array of
  185.  
  186.                  *buffer[3]=characters
  187.  
  188. Any normal varible type that can be defined can also be
  189.  
  190. defined as a pointer.
  191.  
  192.  
  193.  
  194. HOW TO USE POINTERS:
  195.  
  196.      Example:
  197.  
  198.      1)     int x=1,y=2,z=3;
  199.  
  200.      2)     int *xx,*yy,*zz;
  201.  
  202.      3)     xx=&x;
  203.  
  204.      4)     yy=&y;
  205.  
  206.      5)     zz=&z;
  207.  
  208.      6)     printf(" x= %d\n y= %d\n z= %d\n",x,y,z);
  209.  
  210.      7)     printf(" *xx=%d\n*yy=%d\n*zz=%d\n",*xx,*yy,*zz);
  211.  
  212.      8)     printf(" &x=%u\n &y=%u\n &z=%u\n",&x,&y,&z);
  213.  
  214.      9)     printf(" xx=%u\n yy=%u\n zz=%u\n",xx,yy,zz);
  215.  
  216. Alright you know that a pointer "points" to the address where
  217.  
  218. a varible is stored.  Right, good now here is where we start
  219.  
  220. to get tricky.  The '&' operater means "the address of" and *
  221.  
  222. means "what is pointed to by."
  223.  
  224. So in line 3 you would want to read it as "xx equals the
  225.  
  226. address of x."  There for you now know that the pointer xx is
  227.  
  228. pointing to the varible x.  If you follow that reasoning you
  229.  
  230. could come up with the conclusion that in line 7 where we are
  231.  
  232. printing out what is being pointed to by xx it should be the
  233.  
  234. same value as x.  Try to figure out what will be printed out
  235.  
  236. before you run this program and then see if you are right.
  237.  
  238. If so continue on.
  239.  
  240.  
  241.  
  242.  
  243.  
  244. VARIBLES AND FUNCTIONS:
  245.  
  246.      Earlier we stated the fact that we use pointers to
  247.  
  248. change the value of a varible in a function that was passed
  249.  
  250. to it.  With out pointers you could only return one varible
  251.  
  252. from a function but with pointers you can change many
  253.  
  254. varibles and have them stay changed when you leave the
  255.  
  256. function.  This section will show you how it is done.
  257.  
  258.      Example:
  259.  
  260.      1)   main() {
  261.  
  262.      2)   int x=0,y=0;
  263.  
  264.      3)   printf("x=%d/ny=%d",x,y);
  265.  
  266.      4)   change(&x,&y);
  267.  
  268.      5)   printf("x=%d\ny=%d",x,y);
  269.  
  270.      6)   }
  271.  
  272.      7)   change(int *x,int *y) {
  273.  
  274.      8)   *x=3;
  275.  
  276.      9)   *y=5; }
  277.  
  278. This program will change the varible x and y to 3 and 5
  279.  
  280. respectively and they will remain changed when they return to
  281.  
  282. the main function.  Now we can return more than one varible
  283.  
  284. from a function.
  285.  
  286.      When you pass an array of pointers to a function you
  287.  
  288. don't have to pass each element of the array you can pass
  289.  
  290. just the name.  For example if you have an array of intergers
  291.  
  292. defined as int *num={ 5, 10, 15, 20 } when you call the
  293.  
  294. function you can call it like this 'function(num)' and the
  295.  
  296. whole array will be passed.
  297.  
  298.  
  299.  
  300.  
  301.  
  302. MISC POINTER FUNCTIONS:
  303.  
  304.      Say for example you have two pointers and you want to
  305.  
  306. point to the same address:
  307.  
  308.      pointer1=pointer2
  309.  
  310. and it is done.
  311.  
  312.      Say you have a pointer to an array and you want to go to
  313.  
  314. the next element in the array:
  315.  
  316.      pointer++
  317.  
  318. and it is done.  Maybe you want to go to the previous
  319.  
  320. element:
  321.  
  322.      pointer--
  323.  
  324. and it is done.
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. POINTERS AND MY LIBARIES:
  333.  
  334.      I used a lot of pointers in my menu libary mainly
  335.  
  336. because I am using direct memory addressing and it make it a
  337.  
  338. lot easier to use pointer rather than varibles.  I also tend
  339.  
  340. to wnat to pass more than one varible back the the parent
  341.  
  342. function.  You have a basic understanding of pointers now so
  343.  
  344. you should be able to understand must of what I am doing with
  345.  
  346. them.  For more infomation you can look an almost any C
  347.  
  348. manual and they will give you about a ten to fifteen page
  349.  
  350. lession on pointers.  If you still have question fill free to
  351.  
  352. contact me.
  353.  
  354.  
  355.  
  356. INTERRUPTS:
  357.  
  358.  
  359.  
  360.      Interrupts are a neat and somtimes tricky part of your
  361.  
  362. DOS and BIOS enviroment.  If you are not sure what they are
  363.  
  364. and how they work pick up almost any DOS reference manual and
  365.  
  366. turn to the interrupt section and start reading you can find
  367.  
  368. a LOT of interesting things that you can put in your programs
  369.  
  370. that you throught were impossible to do.
  371.  
  372.      An interrupt is a signal to the processor from a program
  373.  
  374. that tells the processor to temporarily suspend the current
  375.  
  376. function that the CPU is working on and proform another task
  377.  
  378. defined by the interrupt function number.  Each interrupt
  379.  
  380. function has a section of coded called an interrupt service
  381.  
  382. routine that is memory resident just like any TSR program.
  383.  
  384. So each time your program call an inter